﻿Public Class DmTinhThanh

    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If keyData = (Keys.Control Or Keys.N) Then
            Return Me.DmtinhthanhIUltraGrid.getTaoMoi()
        End If
        If keyData = (Keys.Control Or Keys.S) Then
            Me.DmtinhthanhIUltraGrid.getLuu()
            Return True
        End If
        If keyData = (Keys.Control Or Keys.D) Then
            Return Me.DmtinhthanhIUltraGrid.getXoa()
        End If
        If keyData = (Keys.Control Or Keys.P) Then
            Return Me.getIn()
        End If
        If keyData = (Keys.Control Or Keys.R) Then
            Return Me.DmtinhthanhIUltraGrid.getRefresh()
        End If
        If keyData = (Keys.Control Or Keys.Q Or Keys.Escape) Then
            Return getThoat()
        End If
        If keyData = (Keys.Control Or Keys.E) Then
            Return Me.DmtinhthanhIUltraGrid.getSua()
        End If
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function

    Private Sub DmTinhThanh_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Cursor = Cursors.WaitCursor 'thêm Cursors(con trỏ) để tạo đồng hồ cát
        'TODO: This line of code loads data into the 'ErpharmaDataSet.dmquocgia' table. You can move, or remove it, as needed.
        Me.DmquocgiaTableAdapter.Fill(Me.ErpharmaDataSet.dmquocgia)
        'TODO: This line of code loads data into the 'ErpharmaDataSet.dmtinhthanh' table. You can move, or remove it, as needed.
        Me.DmtinhthanhTableAdapter.Fill(Me.ErpharmaDataSet.dmtinhthanh)
        Me.DmtinhthanhIUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmtinhthanh, Me.DmtinhthanhBindingSource, Me.DmtinhthanhTableAdapter, Me.ErpharmaDataSet)
        Me.DmtinhthanhIUltraGrid.setGiaoDienVua()
        Me.DmtinhthanhIUltraGrid.setTimKiemTrenCotUltraGrid()
        Me.DmtinhthanhIUltraGrid.setChoPhepLuuXongKhongThemDong() 'sau khi lưu thì không hiện lên dòng trống ở cuối lưới
        Me.DmtinhthanhIUltraGrid.setChoPhepMenuStrip()
        'Me.DmtinhthanhIUltraGrid.setChoPhepMenuStrip_SaveXml() 'luu 2 file xml

        Me.DmtinhthanhIUltraGrid.setThemIUltraDropDown(Me.DmquocgiaIUltraDropDown, Me.ErpharmaDataSet.dmquocgia)
        Me.DmquocgiaIUltraDropDown.setGiaoDien_An_ColumnHeader()
        Me.DmtinhthanhIUltraGrid.setReadonly(True)
        Me.Cursor = Cursors.Default ' trở về mặc định con trỏ
    End Sub

    Private Sub btnTaoMoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTaoMoi.Click
        Me.DmtinhthanhIUltraGrid.getTaoMoi()

    End Sub

    Private Sub btnLuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLuu.Click
        Me.DmtinhthanhIUltraGrid.getLuu()

    End Sub

    Private Sub btnXoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXoa.Click
        Me.DmtinhthanhIUltraGrid.getXoa()

    End Sub

    Private Sub btnLamTuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLamTuoi.Click
        Me.DmtinhthanhIUltraGrid.getRefresh()

    End Sub

    Private Sub btnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIn.Click
        getIn()
    End Sub
    'Nut in tao ham get in
    Private Function getIn() As Boolean
        Try
            Dim rp As DMTinhThanh_Report = New DMTinhThanh_Report
            rp.setDt(Me.DmtinhthanhIUltraGrid.getDatatableTuIUltraGrid("dmtinhthanh"))
            rp.Show()
            Me.DmtinhthanhIUltraGrid.DataSource = Me.ErpharmaDataSet.dmtinhthanh
        Catch ex As Exception
            Return MessageBox.Show(ex.ToString, "Thong bao")
        End Try
        Return True
    End Function
    'Nut thoat tao ham getThoat
    Private Function getThoat() As Boolean
        Try
            If Me.DmtinhthanhIUltraGrid.getClose Then
            End If
            Me.Dispose()
            Me.Close()
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        getThoat()
    End Sub

    Private Sub btnSua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSua.Click
        Me.DmtinhthanhIUltraGrid.getSua()

    End Sub
End Class